<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class ScheduleUser_model extends CI_Model {

    public $tablename = 'hpg_schedule_user';
    
    public $tabuser = 'hpg_user';
    
    public function getUidList($schedule_ids){
        if( !$schedule_ids || !is_array($schedule_ids) ){
            return false;
        }
        $list = $this->db->select('schedule_id,uid,status')->from($this->tablename)
        ->where_in('schedule_id', $schedule_ids)
        ->get_array();
        $returndata = [];
        foreach($list as $v){
            $returndata[$v['schedule_id']][] = $v;
        }
        return $returndata;
    }
    
    public function getUserList($schedule_ids){
        if( !$schedule_ids || !is_array($schedule_ids) ){
            return false;
        }
        $list = $this->db->select('a.schedule_id,a.uid,a.status,b.user_name,b.photo')->from($this->tablename.' as a')->join($this->tabuser.' as b', 'a.uid=b.id')
        ->where_in('a.schedule_id', $schedule_ids)
        ->get_array();
        $returndata = [];
        foreach($list as $v){
            $returndata[$v['schedule_id']][] = $v;
        }
        return $returndata;
    }
    
    public function update($map, $data){
        if( !$map || !$data ){
            return false;
        }
        $res = $this->db->update($this->tablename, $data, $map);
        return $res;
    }
    
}
?>